Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request for PyVerse 💡
Requesting to submit a pull request to the PyVerse repository.
Issue Title
Please enter the title of the issue related to your pull request.
IoT Device Control Using MQTT and Python
Info about the Related Issue
What's the goal of the project?
The aim of this project is to develop a Python-based application for controlling IoT devices using the MQTT protocol. It focuses on establishing secure, reliable communication between the application and IoT devices through an MQTT broker. The project incorporates advanced features such as TLS/SSL for secure data transmission, dynamic topic management for flexible device interaction, and robust error handling to ensure seamless operation. Additionally, it includes logging capabilities to monitor and troubleshoot the application's behavior. This setup is designed to facilitate two-way communication, allowing the application to send commands to IoT devices and receive responses, making it suitable for complex IoT environments.
Name
Please mention your name.
Dinmay Kumar Brahma
GitHub ID
Please mention your GitHub ID.
dino65-dev
Email ID
Please mention your email ID for further communication.
[email protected]
Identify Yourself
Mention in which program you are contributing (e.g., WoB, GSSOC, SSOC, SWOC).
GSSOC-EXT 24
CONTRIBUTOR
I have mentioned my participant role.
Closes
Enter the issue number that will be closed through this PR.
*Closes: #1042 *
Describe the Add-ons or Changes You've Made
Give a clear description of what you have added or modified.
Secure Communication:
tls_set()
method on the MQTT client, which ensures that data exchanged between the client and broker is encrypted.Dynamic Topic Management:
response_topic
) upon successful connection. This enables the client to listen for messages from the IoT device.Enhanced Error Handling:
on_connect
callback function checks the connection result code (rc
) and logs whether the connection was successful or failed.Logging:
logging
module to provide detailed logs for various events, such as successful connections, message receipt, and errors. This helps in monitoring the application's behavior and diagnosing issues.Callback Functions:
Loop Management:
client.loop_start()
to handle network traffic and callbacks in a separate thread, allowing the script to remain responsive and continuously listen for incoming messages.These enhancements make the script more robust, secure, and suitable for advanced IoT applications where secure communication and feedback from the device are necessary.
Type of Change
Select the type of change:
How Has This Been Tested?
Describe how your changes have been tested.
I have described my testing process in readme file.
Checklist
Please confirm the following: